<?php
/*
Extension Name: @@EXTENSIONNAME@@
Extension Url: n/a
Description: [experimental] Add OpenID to vanilla
Version: @@VERSION@@
Author: Dinoboff
Author Url: http://lussumo.com/community/account/2469/
*/

define('OPENID_DIR', str_replace('\\', '/', dirname(__FILE__)));

/**
 * include/Auth need to be in include path
 * @todo Check the setting is changed and thought an error message if it is not.
 */

include(OPENID_DIR . '/library/Class.OpenID_UserManager.php');
include(OPENID_DIR . '/library/Class.OpenID_User.php');
include(OPENID_DIR . '/library/Class.OpenID_OpenIdManager.php');
include(OPENID_DIR . '/library/Control.OpenID_SignInForm.php');
include(OPENID_DIR . '/library/Control.OpenID_ApplyForm.php');
include(OPENID_DIR . '/library/Functions.php');


/**
 * Add extension settings to conf/settings.php, some settings to conf/database.php
 * and add a table and a field in the usre table.
 */
OpenID_Setup($Context, '0.1.0', OPENID_DIR . '/');

if (in_array($Context->SelfUrl, array('account.php', 'people.php'))) {
	/**
	 * Extends User and UserManager
	 */
	$Context->ObjectFactory->SetReference("User", "OpenID_User");
	$Context->ObjectFactory->SetReference("UserManager", "OpenID_UserManager");

	/**
	 * extends the divers people controller
	 */
	$Context->ObjectFactory->SetReference("SignInForm", "OpenID_SignInForm");
	$Context->ObjectFactory->SetReference("ApplyForm", "OpenID_ApplyForm");
	//$Context->ObjectFactory->SetReference("PasswordResetForm", "OpenID_PasswordResetForm");
}